<template>
  <div class="home-page">
    <el-container>
      <el-aside width="200">
        <!-- 侧边栏 -->
        <el-menu
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          :router="true"
          :collapse="isCollapse"
        >
          <qf-sub-menu :sideMenu="menuList"></qf-sub-menu>
        </el-menu>
      </el-aside>
      <el-container>
        <!-- 顶部栏 -->
        <el-header>
          <el-row>
            <el-col :span="6"
              ><div class="grid-content bg-purple">
                <i
                  class="iconfont icon-shouqi"
                  @click="isCollapse = !isCollapse"
                ></i></div
            ></el-col>
            <el-col :span="6"
              ><div class="grid-content bg-purple">
                黑暗神殿
              </div></el-col
            >
            <el-col :span="6"
              ><div class="grid-content bg-purple">
                <!-- 头像 -->
                <el-avatar :size="40" fit="fit" :src="squareUrl"></el-avatar>
                <span>欢迎您:</span>
                <b>{{ userInfo.nickname }}</b>
                <span class="quit" @click="quit">退出</span>
              </div></el-col
            >
          </el-row>
        </el-header>
        <!-- 主体部分 -->
        <el-main>
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/Welcome' }"
              >首页</el-breadcrumb-item
            >
            <el-breadcrumb-item
              :to="{ path: crubm.meta.name }"
              v-for="crubm in crubms"
            >
              {{ crubm.meta.name }}
            </el-breadcrumb-item>
          </el-breadcrumb>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { getLoginLog } from "@/api";
import subMnue from "../../components/subMnue";
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["userInfo", "menuList", "crubms"])
  },
  data() {
    return {
      circleUrl:
        "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
      squareUrl:
        "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png",
      sizeList: ["large", "medium", "small"],
      isCollapse: false
    };
  },
  components: {
    subMnue
  },
  mounted() {
    getLoginLog().then(res => {
      // console.log(res);
    });
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    quit() {
      //退出登入
      //1.清空token和userInfo
      //2.跳转到登录页
      localStorage.removeItem("stu-token");
      localStorage.removeItem("stu-userInfo");

      this.$router.push("/login");
      //刷新页面
      window.location.reload();
    }
  }
};
</script>

<style>
/* 页面布局 */
.el-header,
.el-footer {
  background: linear-gradient(to bottom right, #b8fc8f, #2e2504);
  color: #333;
  text-align: center;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

/* header */

.el-row {
  width: 100%;
  height: 100%;
  line-height: 60px;
  color: white;
  display: flex;
  justify-content: space-between;
}
.el-col {
  border-radius: 4px;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  background-color: #f9fafc;
}
/* 头像 */
.el-avatar {
  vertical-align: middle;
}
/* 退出 */
.quit {
  cursor: pointer;
  color: hotpink;
}
/* 收起按钮 */
.icon-shouqi {
  font-size: 60px;
  color: aqua;
  left: 0;
}

/* 侧边栏 */
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>